import {request,requestMock} from '@/utils/http'
//请求首页的三级分类列表
export const requestCategoryList = () => {
    return request.get('/api/product/getBaseCategoryList')
}
//请求banner
export const requestBannerList = () => {
    return requestMock.get('/banner')
}
//请求floor
export const requestFloorList = () => {
    return requestMock.get('/floor')
}
//请求搜索页数据
export const requestSearchList = (listParams) => {
    return request.post('/api/list',listParams)
}
//请求商品详情页数据
export const requestDetailInfo = (skuId) => {
    return request.get(`/api/item/${skuId}`)
}
//添加到购物车，修改商品数量
export const requestAddCartSuccess = ({skuId,skuNum}) => {
    return request.post(`/api/cart/addToCart/${ skuId }/${ skuNum }`)
}
//获取购物车列表
export const requestShopCart = () => {
    return request.get('/api/cart/cartList')
}
//修改单个商品选中状态
export const requestUpdateSingleCheck = (skuID,isChecked) => {
    return request.get(`/api/cart/checkCart/${skuID}/${isChecked}`)
}
//修改购物车所有商品选中状态
export const requestUpdateAllCheck = (isChecked,skuIdList) => {
    return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList)
}
//删除购物车单个商品
export const requestDeleteSingleGood = (skuId) => {
    return request.delete(`/api/cart/deleteCart/${skuId}`)
}
//删除购物车已选的所有商品
export const requestDeleteAllGoods = (skuIdList) => {
    return request.delete(`/api/cart/batchDeleteCart`, {
        data: skuIdList,
    });
}
//获取注册验证码
export const requestRegisterCode = (phone) => {
    return request.get(`/api/user/passport/sendCode/${phone}`)
}
//注册用户
export const requestRegisterUser = (register) => {
    return request.post('/api/user/passport/register',register)
}

//登录请求
export const requestLogin = (userInfo) => {
    return request.post('/api/user/passport/login',userInfo)
}

//通过token获取用户信息
export const requestUserInfo = () => {
    return request.get('/api/user/passport/auth/getUserInfo')
}

//退出登录
export const requestLogout = () => {
    return request.get("/api/user/passport/logout");
};

//获取订单交易页信息
export const requestTradeInfo = () => {
    return request.get('/api/order/auth/trade')
}

//请求购物地址
export const requestTradeAddress = () => {
    return requestMock.get('/address')
}

//提交订单
export const requestAddTrade = (tradeNo,tradeInfo) => {
    return request.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`,tradeInfo)
}

//根据订单号获取订单详细信息
export const requestPayDetail = (orderId) => {
    return request.get(`/api/payment/weixin/createNative/${orderId}`)
}

//查询支付订单状态
export const requestPayStatus = (orderId) => {
    return request.get(`/api/payment/weixin/queryPayStatus/${orderId}`)
}

//获取我的订单列表
export const requestOrderList = ({page,limit}) => {
    return request.get(`/api/order/auth/${page}/${limit}`)
}